﻿@{
    ViewBag.Title = "角色授权";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script language="javascript" type="text/javascript">
    $(function () {
        TreeOnclickRow();
    });
    function TreeOnclickRow(roleId) {
        $('#tts').tree({
            url: '/SystemSet/GetPageUrlJson?roleId=' + roleId,
            method: "post",
            animate: true,
            lines: true,
            checkbox: true
        });
    }


    function PagePurviews() {
        var row = $('#tt').tree('getSelected');
        if (!row) {
            Helper.Show("请选择角色在保存!");
            return false;
        }
        var result = $("#tts").tree('getChecked');
        if (!result) {
            Helper.Show("请选择页面权限在保存!");
            return false;
        }
        var pageId = "";
        for (var i = 0; i < result.length; i++) {
            pageId += result[i].id + ",";
            if (result[i].attributes.parentId != "0") {
                pageId += result[i].attributes.parentId + ",";
            }
        }
        if (pageId == "") {
            Helper.Show("请选择页面权限在保存!");
            return false;
        }
        $.post("/SystemSet/AddPagePurviews", {
            roleId: row.id,
            pageId: pageId
        }, function (json) {
            Helper.Show(json.Msg);
            if (json.Success) {
                doSearch();
            }
        });
    }
</script>
<div id="tb" style="padding: 3px; height: auto; border: 1px solid #red; background-color: #00000;">
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="PagePurviews()">设置权限</a>
    </div>
</div>
<table>
    <tbody>
        <tr>
            <td valign="top" style="width: 200px;">
                <ul id="tt" class="easyui-tree" data-options="url:'/SystemSet/GetRoleJson',method:'post',animate:true,lines:true,onClick: function(node){TreeOnclickRow(node.id);} "></ul>
            </td>
            <td style="width: 200px;"></td>
            <td style="width: 200px;">
                <ul id="tts" class="easyui-tree"></ul>
            </td>
        </tr>
    </tbody>
</table>


